clear
use "\\file\UsersW$\wrr15\Home\My Documents\My Files\PCC PROJECT\DATAVERSE FILES\TABLE1.dta"

// This example is based on data from:
// de Linde Leonard, M., Stanley, T.D., & Doucouliagos, H. (2014). 
// Does the UK minimum wage reduce employmennt? A meta-regression analysis. 
// British Journal of Industrial Relations, 52(3): 499-520.

// Stata 16.0
// October 1, 2019 

local rhsvars unemploy toughness lag published timetrend averageyear ///
 panel dblelog regioncontrol

gen precision = 1/se
gen telasticity = estimatedelasticity/se

preserve
foreach var in `rhsvars' {
replace `var' = `var'/se
}
regress telasticity precision, vce(cluster studyid)
regress telasticity `rhsvars' precision, vce(cluster studyid)
restore

// We now reproduce the above with PCC

local rhsvars unemploy toughness lag published timetrend averageyear ///
 panel dblelog regioncontrol

gen tstat = telasticity
gen pcc = tstat/sqrt(tstat^2+df)
gen varpcc = (1-pcc^2)/df
gen sepcc = sqrt(varpcc)
gen tpcc = pcc/sepcc
gen precisionpcc = 1/sepcc

foreach var in `rhsvars' {
replace `var' = `var'/sepcc
}
regress tpcc precisionpcc, vce(cluster studyid)
regress tpcc `rhsvars' precisionpcc, vce(cluster studyid)